// [物模型] 接口
import { axios } from '@/utils/request';

/**
 * [物模型] 查询指定物模型的指标信息
 * @params params
 * {
    {"id":{"required":true,"type":"integer"}}
   }
 */
export function getDatahubThingIndexes(params) {
  return axios({
    method: 'get',
    url: 'datahub/thing/indexes',
    params
  })
}

/**
 * [物模型] 新增物模型
 * @params data
 * {
    {"description":{"description":"物模型描述","type":"string"}},
    {"name":{"description":"物模型名称","type":"string"}},
    {"thingIndexes":{"description":"物模型指标","type":"array"}},
    {"thingParameters":{"description":"物模型参数","type":"array"}}
   }
 */
export function postDatahubThingModel(data) {
  return axios({
    method: 'post',
    url: 'datahub/thing/model',
    data
  })
}

/**
 * [物模型] 编辑物模型
 * @params data
 * {
    {"description":{"description":"物模型描述","type":"string"}},
    {"id":{"type":"integer"}},
    {"name":{"description":"物模型名称","type":"string"}},
    {"thingIndexes":{"description":"物模型指标","type":"array"}},
    {"thingParameters":{"description":"物模型参数","type":"array"}}
   }
 */
export function putDatahubThingModel(data) {
  return axios({
    method: 'put',
    url: 'datahub/thing/model',
    data
  })
}

/**
 * [物模型] 删除物模型
 * @params params
 * {
    {"id":{"required":true,"type":"integer"}}
   }
 */
export function deleteDatahubThingModel(params) {
  return axios({
    method: 'delete',
    url: 'datahub/thing/model',
    params
  })
}

/**
 * [物模型] 分页查询物模型
 * @params params
 * {
    {"name":{"required":false,"type":"string"}},
    {"pageNo":{"required":false,"type":"integer"}},
    {"pageSize":{"required":false,"type":"integer"}}
   }
 */
export function getDatahubThingModelPage(params) {
  return axios({
    method: 'get',
    url: 'datahub/thing/model-page',
    params
  })
}

/**
 * [物模型] 主动校验
 * @params params
 * {
    {"id":{"required":false,"type":"integer"}},
    {"field":{"required":false,"type":"string"}},
    {"value":{"required":false,"type":"object"}}
   }
 */
export function getDatahubThingModelVerification(params) {
  return axios({
    method: 'get',
    url: 'datahub/thing/model/verification',
    headers: { validate: true },
    params
  })
}

/**
 * [物模型] 查询物模型列表
 * @params params
 * {
    {"name":{"required":false,"type":"string"}}
   }
 */
export function getDatahubThingModels(params) {
  return axios({
    method: 'get',
    url: 'datahub/thing/models',
    params
  })
}